from cache cimport Cacheable
from iterators cimport BufferingIterator

cpdef starting_vertices(graph)
cpdef compatible(v1, v2)
cpdef admissible_vertex_mappings(v, g, ixs)
cpdef extend_map(m, g1, int i1, int r, g2, int i2)
cpdef neighbors(m, g1, int i1, g2, int i2)

cdef class EqualIfIsomorphic(Cacheable):
    cdef readonly invariants
    cdef _cache_eq

cdef class Fatgraph(EqualIfIsomorphic):
    cdef __weakref__
    cdef readonly _cache_isomorphisms
    cdef readonly _cache_bcys
    cdef readonly _cache_edge_orbits
    cdef readonly _cache_edge_pair_orbits
    cdef readonly _cache_valence_spectrum
    cdef readonly edge_numbering
    cdef readonly endpoints_i
    cdef readonly endpoints_v
    cdef readonly int num_edges
    cdef readonly int num_external_edges
    cdef readonly int num_vertices
    cdef readonly vertices
    cpdef automorphisms(self)
    cpdef boundary_cycles(self)
    cdef _cmp_orient(self, other, iso)
    cdef bridge(self, int edge1, int side1, int edge2, int side2)
    cpdef contract(self, int edgeno)
    cdef edge_orbits(self)
    cdef edge_pair_orbits(self)
    cpdef int genus(self)
    cdef hangcircle(self, int edge, int side)
    cpdef bool is_loop(self, int edge)
    cpdef bool is_orientation_reversing(self, automorphism)
    cpdef bool is_oriented(self)
    cpdef isomorphisms(g1, g2)
    cpdef int num_automorphisms(self)
    cpdef int num_boundary_cycles(self)
    cdef other_end(graph, int edge, vertex, int attachment)
    cpdef int projection(self, other)
    cpdef valence_spectrum(self)
    cpdef vertex_valences(self)
    cpdef vertex_valence_distribution(self)

cdef bool unseen(candidate, K, already)
cpdef MakeNumberedGraphs(graph)

cdef sort_by_values_then_by_keys(kv1,kv2)
cdef class NumberedFatgraph(Fatgraph):
    cpdef readonly underlying
    cpdef readonly numbering
    cpdef contract(self, int edgeno)
    cpdef isomorphisms(self, other)

cdef append_if_no_duplicate(lst, item)
cdef _admissible(G, int g, int n)
cpdef MgnTrivalentGraphsRecursiveGenerator(int g, int n)

cdef class MgnGraphsIterator(BufferingIterator):
    cdef readonly int g
    cdef readonly int n
    cdef _batch
    cdef int _num_vertices
    cdef refill(self)

cdef class MgnNumberedGraphsIterator(BufferingIterator):
    cdef __naked_graphs_iterator
    cdef refill(self)
